home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
HardwareCpu.h,v
< prev
next >
Wrap
Text File
|
1988-09-28
|
4KB
|
255 lines
head 1.3;
access ;
symbols ;
locks ; strict;
comment @ * @;
1.3
date 88.09.28.22.13.50; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.09.21.20.51.48; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.09.18.16.42.08; author grunwald; state Exp;
branches ;
next ;
desc
@@
1.3
log
@*** empty log message ***
@
text
@#ifndef HardwareCpu_h
#define HardwareCpu_h
#include "HardwareContext.h"
//
// Define the abstractions for per UNIX process resources.
//
//
// Maximum number of UNIX processes that can be requested. This is
// used to size internal data structures.
//
class Thread;
class ReserveByException;
class AwesimeHeap;
class ThreadContainer;
class HardSpinLock;
class HardwareCpu;
typedef enum
{
ExceptionNull,
ExceptionReserve,
ExceptionTerminateThread,
ExceptionDelay,
ExceptionSwitch
} ExceptionCatagories;
//
// Filled in by the single original UNIX process. This value may
// change during execution
//
extern int HardwareCpus;
extern HardwareCpu *ThisCpu;
//
// Like it says.
//
extern double CurrentSimulatedTime;
extern const double NullTime;
class HardwareCpu {
private:
Thread *currentThread;
HardwareContext systemContext;
ThreadContainer *myCurrentEvents;
HardSpinLock *myCurrentEventsLock;
AwesimeHeap *myPendingEvents;
HardSpinLock *myPendingEventsLock;
int iYam; // I yam what I yam
int pid; // ...except to UNIX
char nameSpace[128];
char *name;
Thread *remove();
void rendezvous();
void advanceTime();
void allocateEventStructures(int);
void deallocateEventStructures();
private:
//
// Exception handlers.
//
ExceptionCatagories raisedBy;
ReserveByException *reserveToBlockOn;
Thread *threadToTerminate;
double timeToDelay;
void raise();
//
// Public interfaces for exceptions
//
public:
void reserveByException( ReserveByException * );
void threadTerminateException( Thread * );
void delayException( double time );
public:
HardwareCpu(int debug = 0);
~HardwareCpu();
void fireItUp(int Cpus = 1, unsigned shared = (4196 * 500));
void stirItAround();
void coolItDown();
void terminateSimulation();
void add(Thread *, double when);
Thread * CurrentThread();
void debug(int newdebug);
int debug();
int cpuId();
};
inline Thread *
HardwareCpu::CurrentThread()
{
return( currentThread );
}
inline int HardwareCpu::cpuId()
{
return( iYam );
}
inline void
HardwareCpu::reserveByException( ReserveByException *sem )
{
raisedBy = ExceptionReserve;
reserveToBlockOn = sem;
raise();
}
inline void
HardwareCpu::threadTerminateException( Thread *killMe )
{
raisedBy = ExceptionTerminateThread;
threadToTerminate = killMe;
raise();
}
inline double simulatedClock() {
return( CurrentSimulatedTime );
}
inline Thread *
CurrentThread()
{
return( ThisCpu -> CurrentThread() );
}
inline void hold(double holdFor)
{
ThisCpu -> delayException(holdFor);
}
//
// These are things the user needs to define
//
extern ThreadContainer *AllocateHardwareCurrentEventsStructure();
#endif /* HardwareCpu_h */
@
1.2
log
@*** empty log message ***
@
text
@a13 1
static const int HardwareCpusMax = 16;
d136 1
a136 1
inline double clock() {
@
1.1
log
@Initial revision
@
text
@d10 6
d18 4
d23 8
a30 4
typedef enum {ExceptionNull,
ExceptionReserve,
ExceptionTerminateThread,
ExceptionDelay } ExceptionCatagories;
d32 13
a45 1
d50 5
d62 1
d64 2
a92 2
void rendezvous();
d104 2
a113 4
//
// Filled in by the single original UNIX process.
extern int HardwareCpus;
extern HardwareCpu *ThisCpu;
d115 1
a115 2
inline Thread *
CurrentThread()
d117 1
a117 1
return( ThisCpu -> CurrentThread() );
d121 7
a127 5
//
// Like it says.
//
extern double CurrentSimulatedTime;
extern const double NullTime;
d129 7
d141 7
d153 5
a157 1
extern double cputime();
@